﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
using System.IO.IsolatedStorage;
using System.Diagnostics;

namespace MayhemWinPhone
{
    public static class Log
    {
#if DEBUG
        const string FILE_NAME = "errors.txt";
        static StreamWriter writer;
        static IsolatedStorageFile isoStorage;
        static IsolatedStorageFileStream file;
#endif
        static Log()
        {
#if DEBUG
            isoStorage = IsolatedStorageFile.GetUserStoreForApplication();
            file = isoStorage.OpenFile(FILE_NAME, FileMode.OpenOrCreate);

            writer = new StreamWriter(file);
            writer.AutoFlush = true;
#endif
        }

        public static string Read()
        {
#if DEBUG
            StreamReader reader = new StreamReader(file);
            return reader.ReadToEnd();
#else
            return "";
#endif
        }

        public static void Write(string s)
        {
#if DEBUG
            Debug.WriteLine(s);
            writer.WriteLine(s);
#endif
        }
    }
}
